home *** CD-ROM | disk | FTP | other *** search
/ DC Comics: Collected Edit…& Graphic Novels Library / DC Comics: Collected Editions & Graphic Novels Library.iso / pc / scripts / datecheck.js < prev    next >
Encoding:
Text File  |  2003-05-08  |  1.3 KB  |  33 lines

  1. <SCRIPT type="text/javascript" LANGUAGE="JavaScript">
  2.  
  3. var wholedate; var wholedatestring; var mo; var day; var yr; var d;
  4.  
  5. var gotEm = false;
  6. var todayDate = myDate.getDate();  // day number 1-31
  7. var todayDay = myDate.getDay();  // day of week 1-7
  8. var todayTime = myDate.getTime();  // milliseonds!!
  9. var oneDay = 86400000;  // # of milliseconds in one day
  10. var mostRecent = todayTime;  //stores most recent distribution date in milliseconds
  11.  
  12. //find the nearest wednesday distribution date
  13. if (todayDay<3) { mostRecent = todayTime-((4+todayDay)*oneDay) }  // readjust mostRecent
  14. else if (todayDay>3) { mostRecent = todayTime-((todayDay-3)*oneDay) }  // readjust mostRecent
  15.  
  16. //traverse the list and make comparisons!
  17. for (var i=0 ; i<=cm_dc_itemStoredate.length-1 ; i++) {
  18.     d = new Date();
  19.     wholedate = cm_dc_itemStoredate[i].split(" ");
  20.     mo = wholedate[0];
  21.     day = wholedate[1].substring(0,wholedate[1].length-3);
  22.     yr = wholedate[2];
  23.     wholedatestring = (mo + ", " + day + " " + yr); 
  24.     d.setTime(Date.parse(wholedatestring));
  25.     testtime = d.getTime();
  26.     if ( (testtime>mostRecent-oneDay) && (testtime<mostRecent+oneDay) ) { //ok, we've got it!
  27.         document.write("  » <a href=\"dc_display.html?cm_dc_itemCode=" + cm_dc_itemCode[i] + "&month=" + month + "\">");
  28.         document.write(cm_dc_itemTitle[i] + "</a><br>");
  29.     }
  30.     else if (gotEm==true) {break;}
  31. }
  32. </script>
  33.